﻿<%@ Page Language="C#" MasterPageFile="../../main.master" Inherits="VioletDevelopmentLaboratory.Net.Web.PageBase" %>

<script runat="server">

	protected void Page_Load(object sender, EventArgs e)
	{
		if (!Page.IsPostBack)
			this.ListBind();
	}

	protected void ListBind()
	{
		ListGridView.DataSource = Board.GetBoardCollection();
		ListGridView.DataBind();
	}

	protected void ListGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
	{
		switch (Board.Remove(ListGridView.DataKeys[e.RowIndex].Value.ToString()))
		{
			case BoardDeleteResult.Success :
				VUtility.ShowAlert(Page, "게시판이 삭제되었습니다.");
				this.ListBind();
				break;
			default :
				VUtility.ShowAlert(Page, "알 수 없는 게시판입니다.");
				break;
		}
	}
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">

	<h2>게시판 &gt; 목록</h2>

	<asp:GridView ID="ListGridView" runat="server" AutoGenerateColumns="False" 
		DataKeyNames="ComponentID" Width="100%" PageSize="20" 
		EmptyDataText="No Rows" onrowdeleting="ListGridView_RowDeleting">
		<Columns>
			<asp:HyperLinkField DataNavigateUrlFields="ComponentID" DataNavigateUrlFormatString="modify.aspx?id={0}"
				DataTextField="ComponentID" HeaderText="아이디" />
			<asp:BoundField DataField="Name" HeaderText="이름" />
			<asp:BoundField DataField="ThreadLimit" HeaderText="글수제한" >
				<ItemStyle HorizontalAlign="Center" />
			</asp:BoundField>
			<asp:CheckBoxField DataField="UseReply" HeaderText="답글" >
				<ItemStyle HorizontalAlign="Center" />
			</asp:CheckBoxField>
			<asp:CheckBoxField DataField="UseComment" HeaderText="댓글" >
				<ItemStyle HorizontalAlign="Center" />
			</asp:CheckBoxField>
			<asp:CheckBoxField DataField="UseFileUpload" HeaderText="파일첨부" >
				<ItemStyle HorizontalAlign="Center" />
			</asp:CheckBoxField>
			<asp:BoundField DataField="CreationDate" HeaderText="추가날짜" >
				<ItemStyle HorizontalAlign="Center" />
			</asp:BoundField>
			<asp:TemplateField>
				<ItemTemplate>
					<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="제거" OnClientClick="<%$ Resources:VGlobalResources, General_Script_RemoveConfirm %>" />
				</ItemTemplate>
				<ItemStyle HorizontalAlign="Center" />
			</asp:TemplateField>
		</Columns>
	</asp:GridView>

</asp:Content>